aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/fund/[id]/sweep/+page.server.js
blob: 613cf8e289df3f32e8b25e1db1c9f54c3034a4c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { get, auth, post } from "$lib/utils";
import { redirect } from "@sveltejs/kit";

export async function load({ cookies, params, parent }) {
  let { user } = await parent();
  let { id } = params;
  let { amount } = await get(`/fund/${id}`);

  if (!amount) redirect(307, `/fund/${id}`);
  if (!user) redirect(307, `/register?redirect=/fund/${id}/sweep`);
  await post("/take", { amount, id }, auth(cookies));
  return { amount, id };
}